def chunk_bytes(data, chunk_size=1024):
    """将二进制数据按指定大小分片"""
    return [data[i:i+chunk_size] for i in range(0, len(data), chunk_size)]

# 示例用法
binary_data = b'\x01\x02\x03' * 400  # 3*400字节的示例数据
chunks = chunk_bytes(binary_data)
for it in chunks:
    print(f"len: {len(it)}")

if __name__ == "__main__":
    multiples=[200,300,400,500]
    for mult in multiples:
        binary_data = b'\x01\x02\x03' * mult
        chunks = chunk_bytes(binary_data)
        print(f"{3*mult} 字节, 分片结果:")
        for it in chunks:
            print(f"len: {len(it)}")